#include <iostream>
#include <sstream>
#include <string>
#include <map>
#include <QApplication>
#include <sstream>
#include <QtGui>

#include "Card.h"
#include "PokerTool.h"

using namespace std;


Card::Card()
{
 libelle = "";
 numero = -1;
 imgPath = "";
 cardColor = ' ';
 cardName=' ';
}

Card::Card(int n, QString lib, QString cimg, QChar coul, QChar _cardName)
{
 numero = n;
 libelle = lib;
 cardColor = coul;
 imgPath = cimg;
 cardName = _cardName;
}

Card::Card(const Card & card)
{
 libelle   = card.libelle;
 numero    = card.numero;
 imgPath   = card.imgPath;
 cardColor = card.cardColor;
 cardName  = card.cardName;
}

Card & Card::operator = (const Card & card)
{
 libelle = card.libelle;
 numero = card.numero;
 imgPath = card.imgPath;
 cardColor = card.cardColor;
 cardName = card.cardName;

 return *this;
}

/**
 * Getter
 */
int Card::getNumero()
{
 return numero;
}

QString Card::getLibelle()
{
 return libelle;
}

QString Card::getImgPath()
{
 return imgPath;
}

QChar Card::getCardName()
{
 return cardName;
}

QChar Card::getCardName()const
{
 return cardName; 
}

QChar Card::getCardColor()
{
 return cardColor;
}

/**
 * Setter
 */
void Card::setNumero(int _numero)
{
 numero = _numero;
}

void Card::setLibelle(QString _libelle)
{
	libelle = _libelle;
}

void Card::setImgPath(QString _imgPath)
{
 imgPath = _imgPath;
}

void Card::setCardName(QChar _cardName)
{
 cardName = _cardName;
}

void Card::setCardColor(QChar _cardColor)
{
 cardColor = _cardColor;
}

QString Card::toString()
{
 string num = PokerTool::intToString(numero);

 QString ret = "carte[";
 ret.append(libelle);
 ret.append(",");
 ret.append( cardColor );
 ret.append(",");
 ret.append( num.c_str() );
 ret.append(",");
 ret.append( cardName );
 ret.append("]");

 return ret;
}

QDomElement Card::toXml(QDomDocument doc)
{
 QDomElement cardElement = doc.createElement("card");
 QDomElement cardNameElement = doc.createElement("cardName");
 QDomElement cardColorElement = doc.createElement("cardColor");
 QDomText cardNameText = doc.createTextNode(cardName);
 QDomText cardColorText = doc.createTextNode(cardColor);

 cardNameElement.appendChild(cardNameText);
 cardColorElement.appendChild(cardColorText);

 cardElement.appendChild(cardNameElement);
 cardElement.appendChild(cardColorElement);

 return cardElement;
}
